package com.sims.service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;

import com.sims.bean.ScoreRecord;
import com.sims.bean.Student;
import com.sims.dao.IScoreRecordDAO;
import com.sims.dao.IStudentDAO;
import com.sims.util.Constant;
import com.sims.util.HttpSessionUtil;

public class ScoreRecordService {
	@Autowired
	IScoreRecordDAO scoreRecordDAO;
	@Autowired
	IStudentDAO studentDAO;

	/** 老师学生均可调用
	 * @param classId
	 * @param year
	 * @param month
	 * @param scoreRecordList
	 * @return
	 */
	public Map<String, String> findScoreRecord(Student student, List<ScoreRecord> scoreRecordList) {
		Map<String, String> result = new HashMap<String, String>();
		
//		List<Student> stuInClass = studentDAO.findByCid(HttpSessionUtil.getUserClassId());
//		
//		List<ScoreRecord> temp = null;
//		
//		for (Student student : stuInClass) {
//			temp = scoreRecordDAO.findBySid(student.getSid());
//			for (ScoreRecord scoreRecord : temp) {
//				scoreRecordList.add(scoreRecord);
//			}
//		}
		
		List<ScoreRecord> temp = scoreRecordDAO.findBySid(student.getSid());
		for (ScoreRecord scoreRecord : temp) {
			scoreRecordList.add(scoreRecord);
		}
		
		result.put(Constant.SUCCESS, null);
		return result;
	}

	/** 添加一个学生一门课的成绩
	 * @param scoreRecord
	 * @return
	 */
	public Map<String, String> addScoreRecord(ScoreRecord scoreRecord) {
		Map<String, String> result = new HashMap<String, String>();

		scoreRecordDAO.attachDirty(scoreRecord);
		
		result.put(Constant.SUCCESS, null);
		return result;
	}
}
